import Cookies from 'js-cookie'

const state = {
    userinfo: Cookies.get('businessInfo') === undefined ? {} : JSON.parse(Cookies.get('businessInfo'))
}

const getters = {
    getUserInfo() {
        return JSON.parse(Cookies.get('businessInfo'));
    }
}

const mutations = {
    SET_USERINFO(state, userinfo) {
        state.userinfo = userinfo;
        Cookies.set('businessInfo', JSON.stringify(userinfo))
    }
}

const actions = {
    setUserInfo({commit}, userInfo) {
        commit("SET_USERINFO", userInfo);
    }
}
export default {
    namespaced: true,
    state,
    mutations,
    actions,
    getters
}